package test1;

import java.time.LocalDate;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-11-23
 * Time: 9:20
 */

/**
 * 理财金卡
 */
public class FinancialCard extends ICBCBankCard implements InterestCounter{
    //利率
    double interest = 0.01;

    public FinancialCard(String uid, String uname) {
        super(uid, uname);
    }

    public FinancialCard(String uid, String uname, double firstMoney) {
        super(uid, uname, firstMoney);
    }

    /**
     * 计算利息的方法
     * @param money   存款金额
     * @param interest 利率
     * @param start  存款开始时间
     * @param end    存款结束时间
     * @return
     */
    @Override
    public String countInterest(double money, double interest, LocalDate start, LocalDate end) {
        CountDays countDays = new CountDays();
        //计算两个日期相差天数
        long day = countDays.countDay(start, end);
        //将利率*天数 并转化为2位小数的String
        DecF decF = new DecF();
        return  decF.checkDoubleFormat(day * interest*money);
    }
}
